package com.gexin.model.order;

import com.gexin.model.order.base.BaseOrderCart;
import com.gexin.model.product.ProductSku;

import java.util.List;

/**
 * 业务名称:  t_order_cart(购物车订单信息) 
 */
@SuppressWarnings("serial")
public class OrderCart extends BaseOrderCart<OrderCart> {
	public static final OrderCart dao = new OrderCart();

	public OrderCart findByUserIdAndSkuId(Integer userId , String skuId) {
		OrderCart orderCart = findFirst("select  *  from t_order_cart where user_id=? and sku_id=?" , userId , skuId);
		return orderCart;
	}

	public List<OrderCart> findByUserAll(Integer user_id){
		List<OrderCart> carts=OrderCart.dao.find("select  c.id as cart_id,c.user_id,c.product_id,c.sku_id,c.sku_txt,c.unit_price,c.nums,p.*  from t_order_cart c  LEFT JOIN t_products p on c.product_id = p.id where c.user_id = ? ORDER BY c.createtime desc  ",user_id);
		return carts;
	}

}
